<template>
  <div id="login">
    <div class="login-box">
      <div class="logo">
        <el-image
          src="https://5b0988e595225.cdn.sohucs.com/images/20190610/eb1593a3a9914b4ebe0f90419aa0e193.jpeg"
          fit="fill"
          :lazy="true"
        ></el-image>
      </div>
      <el-form ref="formRef" :model="form" :rules="rules">
        <el-form-item prop="username">
          <el-input class="input" placeholder="用户名" :prefix-icon="User" v-model="form.username"></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input
            class="input"
            placeholder="密码"
            type="password"
            :prefix-icon="Lock"
            v-model="form.password"
          ></el-input>
        </el-form-item>
        <div class="btns">
          <el-button type="primary" class="btn" @click="loginBtn">登录</el-button>
          <div class="btn reset">重置</div>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script setup lang='ts'>
import { ref } from "vue";
import { User, Lock } from "@element-plus/icons-vue";
import type { FormInstance } from "element-plus";
import { rules } from "@/rules/userInfo";
import { loginApi } from "@/api/login";


interface Form {
  username: string;
  password: string;
}

const form = ref<Form>({
  username: "admin",
  password: "admin"
});

const formRef = ref<FormInstance>();


const loginBtn = async () => {
  console.log("````");
  const res = await loginApi(form.value);
  console.log(res);
}

</script>

<style lang='scss' scoped>
#login {
  height: 100vh;
  background: #94acda;
  background: -webkit-linear-gradient(top left, #94acda 0%, #ee9ca7 100%);
  background: linear-gradient(to bottom right, #94acda 0%, #ee9ca7 100%);
  opacity: 0.9;
  display: flex;
  justify-content: center;
  align-items: center;
  .login-box {
    width: 360px;
    height: 450px;
    background-color: #fff;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    .logo {
      width: 120px;
      height: 120px;
      border-radius: 50%;
      box-shadow: 0 0 10px #000;
      margin-bottom: 20px;
      overflow: hidden;
    }
    .el-form {
      width: 90%;
      margin-top: 30px;
      .input {
        height: 40px;
        :deep(.el-input__wrapper) {
          border-radius: 20px;
          border: 1px solid #ccc;
        }
      }

      .btns {
        display: flex;
        flex-direction: column;
        align-items: center;

        .btn {
          width: 100%;
          height: 40px;
          border-radius: 20px;
          cursor: pointer;
        }

        .reset {
          margin-top: 20px;
          text-align: center;
        }
        .reset :hover {
          color: #227dc9;
        }
      }
    }
  }
}
</style>